<template>
  <div>
    <Suspense>
      <transition appear name="fade-transform" mode="out-in">
        <RouterView />
      </transition>
      <!-- <div>
      <router-view v-slot="{ Component }">
        <transition appear name="fade-transform" mode="out-in">
          <keep-alive>
            <component :is="Component" />
          </keep-alive>
        </transition>
      </router-view>
    </div> -->
    </Suspense>
  </div>
</template>

<script setup lang="ts">
import { provide } from 'vue';
import { useAddress } from './store/user'
import { useCoupon } from './store/Coupon'
import { ref, nextTick } from 'vue'

//初始化地址
const address = useAddress()
const coupon = useCoupon()
let couponList = localStorage.getItem('couponList')
address.addressGetAction()

//跳转后页面刷新
// provide("reload1",reload)

// const isRouterAlive = ref(true)
// const reload=ref(
//   ()=>{
//   isRouterAlive.value=false
//   nextTick(function(){
//     isRouterAlive.value=true
//   })
// }
// )

if (couponList) {
  // 保存本地机里面的数据
  coupon.couponInitAction(JSON.parse(couponList))
}

window.onload = function () {
  document.addEventListener('touchstart', function (event) {
    if (event.touches.length > 1) {
      event.preventDefault()
    }
  })
  document.addEventListener('gesturestart', function (event) {
    event.preventDefault()
  })
  // if (document.getElementById('Loading')) {
  //   document.getElementById('Loading').remove();
  // }
}

// nextTick(() => {
//   if (document.getElementById('Loading')) document.getElementById('Loading').remove();
// })
</script>



<style lang="scss" scoped>
.fade-transform-leave-active,
.fade-transform-enter-active {
  transition: all 0.5s;
}

.fade-transform-enter-from {
  opacity: 0;
  transform: translateX(-30px);
}

.fade-transform-leave-to {
  opacity: 0;
  transform: translateX(30px);
}
</style>
